<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath%>">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <%@ include file="../common/baseCss.jsp" %>
    <title>修改站点名</title>
</head>
<body>
<article class="page-container">
    <form action="" method="post" class="form form-horizontal" id="siteEditForm">
        <input type="text" class="input-id" id="siteId" name="siteId" style="display: none;" value="${id}">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">
                <span class="c-red">*</span>名称：
            </label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="站点名称" id="name" name="siteName" value="${siteName}">
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="button" class="btn btn-success radius" id="site-edit" name="site-edit" >提交</button>
            </div>
        </div>
    </form>
</article>
<%@ include file="../common/baseJs.jsp" %>
<script type="text/javascript">
    var rootPath = getRootPath();
    $(function() {
        $("#site-edit").click(function() {
            if(document.forms[0].siteName.value==""){
                layer.alert("名称不能为空");
            }else{
                var name = $('#name').val();
                var sid = $('#siteId').val();
                $.ajax({
                    url:rootPath+"/editSiteName",
                    type:"POST",
                    data:{
                        "siteName":name,
                        "siteId":sid
                    },
                    success:function(data){
                        layer.msg('成功',{icon:1,time:1000},function() {
                            parent.window.location.href = rootPath + '/multiSitePage';
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                    },error: function () {
                        layer.alert("修改失败");
                    }
                });
            }
        })
    })
</script>
</body>
</html>